package com.watson.springtest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.context.WebServerApplicationContext;
import org.springframework.boot.web.servlet.context.WebApplicationContextServletContextAwareProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Scope;

/**
 * @program: mytest
 * @description:
 * @author: zhangpeng348@jd.com
 * @date: 2019-07-23 20:59
 **/
@SpringBootApplication
public class BeanBox {

    @Bean
    public Car putBean() {
        return null;
    }

    @Bean
    @Conditional(Brand.class)
    public Car putXCar() {
        return new Car(new Brand("BMW"));
    }

    @Bean
    @Profile(value = "dev")
    public Car DevCar() {
        return null;
    }

    @Bean
    @Profile(value = "online")
    public Car OnlineCar() {
        return null;
    }

    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public Dessert iceCream() {
        return new IceCream();
    }

    Dessert dessert;

    @Autowired
    @Qualifier(value = "iceCream")
    public void setDessert(Dessert dessert) {
        this.dessert = dessert;
    }

    public static void main(String[] args) {
        SpringApplication.run(BeanBox.class, args);
    }
}
